package org.jasper.constants;

/**
 * Created by OP038074 on 2018/7/9.
 */
public enum MBeansOption {
    ENABLED(true),
    DISABLED(false);

    public static final String PROPERTY_NAME = "kie.mbeans";

    private boolean value;

    MBeansOption(final boolean value) {
        this.value = value;
    }
    public boolean isEnabled() {
        return this.value;
    }

    public static boolean isEnabled(final String value) {
        if( value == null || value.trim().length() == 0 ) {
            return false;
        } else if ( "ENABLED".equalsIgnoreCase( value ) ) {
            return true;
        } else if ( "DISABLED".equalsIgnoreCase( value ) ) {
            return false;
        } else {
            throw new IllegalArgumentException( "Illegal enum value '" + value + "' for MBeans option. Should be either 'enabled' or 'disabled'" );
        }
    }
}
